home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / c_course.zip / GOTOEX.C < prev    next >
Text File  |  1989-12-30  |  1KB  |  38 lines

  1. main()
  2. {
  3. int dog,cat,pig;
  4.  
  5.    goto real_start;
  6.  
  7.    some_where:
  8.    printf("This is another line of the mess.\n");
  9.    goto stop_it;
  10.  
  11. /* the following section is the only section with a useable goto */
  12.    real_start:
  13.    for(dog = 1;dog < 6;dog++) {
  14.       for(cat = 1;cat < 6;cat++) {
  15.          for(pig = 1;pig < 4;pig++) {
  16.             printf("Dog = %d  Cat = %d  Pig = %d\n",dog,cat,pig);
  17.             if ((dog + cat + pig) > 8 ) goto enough;
  18.          };
  19.       };
  20.    };
  21.    enough: printf("Those are enough animals for now.\n");
  22. /* this is the end of the section with a useable goto statement */
  23.  
  24.    printf("\nThis is the first line out of the spaghetti code.\n");
  25.    goto there;
  26.  
  27.    where:
  28.    printf("This is the third line of spaghetti.\n");
  29.    goto some_where;
  30.  
  31.    there:
  32.    printf("This is the second line of the spaghetti code.\n");
  33.    goto where;
  34.  
  35.    stop_it:
  36.    printf("This is the last line of this mess.\n");
  37.  
  38. }